package com.wlz.structural.proxy;


import com.wlz.structural.proxy.jdkproxy.JdkInvocationHandler;

import java.lang.reflect.Proxy;

public class Client {
    public static void main(String[] args) {
        //静态代理
        GamePlayer gamePlayer = new GamePlayer("张三");
//        GamePlayerProxy proxy=new GamePlayerProxy(gamePlayer);
//        proxy.login("张三","1234567");
//        proxy.killBoss();
//        proxy.upgrade();

        //jdk动态代理
        IGamePlayer gamePlayerProxy =
                (IGamePlayer) Proxy.newProxyInstance(
                        Client.class.getClassLoader(),
                        new Class[]{IGamePlayer.class},
                        new JdkInvocationHandler(gamePlayer));

        gamePlayerProxy.killBoss();


    }
}
